<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/layui/layui.js"></script>
    <link rel="stylesheet" href="../js/layui/css/layui.css">
    <script src="../js/jquery/jquery-1.9.1.js"></script>
</head>
<body>
<table id="date" lay-filter="test" ></table>
<div id="toolbar" style="display: none;">
    <a class="layui-btn layui-btn-xs" lay-event="edit">查看详情</a>
</div>
<div id="add-main" style="display: none;">
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">职位名称</label>
            <div class="layui-input-inline">
                <input type="text" id="workname"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">工作地点</label>
            <div class="layui-input-inline">
                <input type="text" id="workingplace" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-inline">
                <input type="text" id="email"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">工作性质</label>
            <div class="layui-input-inline">
                <input type="text" id="worktype" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">期望工资</label>
        <div class="layui-input-block">
            <input type="text" id="wage"  placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">职业行位</label>
        <div class="layui-input-inline">
            <input type="text" id="hangye"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">自我评价</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入内容" class="layui-textarea" id="pingjia"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">求职时间</label>
        <div class="layui-input-block">
            <input type="text" id="qiuzhidate"  placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" style="align-items: center" id="show">
        <div class="layui-inline">
                <button type="button" onclick="updatestatus(2)" class="layui-btn layui-btn-normal">录取</button>
        </div>
        <div class="layui-inline">
                <button type="button"  onclick="updatestatus(3)" class="layui-btn layui-btn-danger">放弃</button>
        </div>
    </div>
    <input type="hidden" id="id">
    <input type="hidden" id="toudistatus">
</div>
</body>
<script>
    var table;
    var layer;
        layui.use(['table','layer','form','element','laydate'], function() {
        table = layui.table;
        layer=layui.layer;
        var laydate = layui.laydate;
        $(function () {
            table.render({
                elem: '#date',
                fit: true,
                id:'table',
                cellMinWidth: true, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                url: '../zsl/queryTouDi', //数据接口
                type: "POST",
                loading: false,
                page: true,//开启分页
                limits: [1, 5, 30, 40, 50, 60, 70, 80, 90],//page 代表当前页码、limit 代表每页数据量
                cols: [
                    [ //表头
                        {type: 'checkbox', fixed: 'left'},
                        {field: 'truename', title: '投递人', align: 'center'},
                        {field: 'roendate', title: '出生日期', align: 'center'},
                        {field: 'startworkdate', title: '工作日期', align: 'center'},
                        {field: 'sex', title: '性别', align: 'center',templet:function (d) {
                                return d.sex == 1? "男":"女";
                            }},
                        {field: 'tel', title: '电话', align: 'center'},
                        {field: 'address', title: '地址', align: 'center'},
                        {field: 'zhiweitype', title: '应聘职位', align: 'center'},
                        {field: 'touch', title: '联系人', align: 'center'},
                        {field: 'haiwai', title: '海外经验', align: 'center', sort: true,templet:function (d) {
                                return d.haiwai+"年"
                            }},
                        {field: 'toudistatus', title: '简历状态',style:'background-color: #009688', align: 'center',templet:function (d) {
                                if (d.toudistatus == 1){
                                    return "未操作"
                                }
                                if (d.toudistatus == 2){
                                    return "同意"
                                }
                                if (d.toudistatus == 3){
                                    return "拒绝"
                                }
                            }},
                        {fixed: 'right',title: '操作', width: 250, align: 'center', toolbar: '#toolbar'}
                    ]
                ]
            });
        })
        // 监听你的表格
        table.on('tool(test)', function(obj) {
            var data = obj.data;
            var id = data.id
            var name = data.name
            if(obj.event==="edit"){
                layer.open({
                    type: 1,
                    title:"招聘岗位详情",
                    closeBtn: false,
                    shift: 2,
                    area: ['800px', '500px'],
                    shadeClose: true,
                    content: $("#add-main"),
                    success: function(layero, index){
                        var temp="";
                        if (data.worktype == 1){
                            temp ="全职";
                        }
                        if (data.worktype == 2){
                            temp ="兼职";
                        }
                        if (data.worktype == 3){
                            temp ="实习";
                        }
                        $("#toudistatus").val(data.toudistatus);
                        $("#id").val(data.toudiId);
                        $('#worktype').val(temp);
                        $('#workname').val(data.workname);
                        $('#workingplace').val(data.workingplace);
                        $('#wage').val(data.wage+"k");
                        $('#hangye').val(data.hangye);
                        $('#email').text(data.email);
                        $('#pingjia').val(data.pingjia);
                        $('#qiuzhidate').val(data.qiuzhidate);
                        $('#miaoshu').val(data.miaoshu);
                        $('#email').val(data.email);
                        $('#daiyuid').val(data.daiyuid);
                        var temp1 = $("#toudistatus").val();
                        if (temp1 != 1){
                            $("#show").hide();
                        }else {
                            $("#show").show();
                        }
                    },
                    yes:function(){
                    }
                });
            }
        })
    })

    function updatestatus(status) {
        var id=$("#id").val();
        $.ajax({
            url:"../zsl/updatestatus",
            data:{id:id,status:status},
            type:'post',
            dataType:'json',
            success:function (data) {
                if (data){
                    alert("修改成功")
                    layer.close(layer.index);
                    table.reload("table",{});

                }else {
                    alert("修改失败")
                }
            }
        })
    }
</script>
</html>